/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author DangThanh
 */
@Entity
@Table(name = "Privmsgs", catalog = "MailServerDB", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Privmsgs.findAll", query = "SELECT p FROM Privmsgs p"),
    @NamedQuery(name = "Privmsgs.findByMsgId", query = "SELECT p FROM Privmsgs p WHERE p.msgId = :msgId"),
    @NamedQuery(name = "Privmsgs.findByFromUserid", query = "SELECT p FROM Privmsgs p WHERE p.fromUserid = :fromUserid"),
    @NamedQuery(name = "Privmsgs.findByToUserid", query = "SELECT p FROM Privmsgs p WHERE p.toUserid = :toUserid"),
    @NamedQuery(name = "Privmsgs.findByMsgSubject", query = "SELECT p FROM Privmsgs p WHERE p.msgSubject = :msgSubject"),
    @NamedQuery(name = "Privmsgs.findByMsgTime", query = "SELECT p FROM Privmsgs p WHERE p.msgTime = :msgTime"),
    @NamedQuery(name = "Privmsgs.findByAttactment", query = "SELECT p FROM Privmsgs p WHERE p.attactment = :attactment")})
public class Privmsgs implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "msg_id", nullable = false)
    private Integer msgId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "from_userid", nullable = false)
    private int fromUserid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "to_userid", nullable = false)
    private int toUserid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "msg_subject", nullable = false, length = 255)
    private String msgSubject;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 2147483647)
    @Column(name = "msg_text", nullable = false, length = 2147483647)
    private String msgText;
    @Basic(optional = false)
    @NotNull
    @Column(name = "msg_time", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date msgTime;
    @Size(max = 255)
    @Column(name = "attactment", length = 255)
    private String attactment;

    public Privmsgs() {
    }

    public Privmsgs(Integer msgId) {
        this.msgId = msgId;
    }

    public Privmsgs(Integer msgId, int fromUserid, int toUserid, String msgSubject, String msgText, Date msgTime) {
        this.msgId = msgId;
        this.fromUserid = fromUserid;
        this.toUserid = toUserid;
        this.msgSubject = msgSubject;
        this.msgText = msgText;
        this.msgTime = msgTime;
    }

    public Integer getMsgId() {
        return msgId;
    }

    public void setMsgId(Integer msgId) {
        this.msgId = msgId;
    }

    public int getFromUserid() {
        return fromUserid;
    }

    public void setFromUserid(int fromUserid) {
        this.fromUserid = fromUserid;
    }

    public int getToUserid() {
        return toUserid;
    }

    public void setToUserid(int toUserid) {
        this.toUserid = toUserid;
    }

    public String getMsgSubject() {
        return msgSubject;
    }

    public void setMsgSubject(String msgSubject) {
        this.msgSubject = msgSubject;
    }

    public String getMsgText() {
        return msgText;
    }

    public void setMsgText(String msgText) {
        this.msgText = msgText;
    }

    public Date getMsgTime() {
        return msgTime;
    }

    public void setMsgTime(Date msgTime) {
        this.msgTime = msgTime;
    }

    public String getAttactment() {
        return attactment;
    }

    public void setAttactment(String attactment) {
        this.attactment = attactment;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (msgId != null ? msgId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Privmsgs)) {
            return false;
        }
        Privmsgs other = (Privmsgs) object;
        if ((this.msgId == null && other.msgId != null) || (this.msgId != null && !this.msgId.equals(other.msgId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "app.entity.Privmsgs[ msgId=" + msgId + " ]";
    }
}
